{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<div class=\"contentcontainer med left\" style=\"margin-left: -50px;\">\n",
    "    <dl class=\"dl-horizontal\">\n",
    "      <dt>Title</dt> <dd> Simple pointer example</dd>\n",
    "      <dt>Description</dt> <dd>A linked streams example demonstrating how us a PointerXY stream to reveal more information about coordinate.</dd>\n",
    "      <dt>Backends</dt> <dd> Bokeh</dd>\n",
    "      <dt>Tags</dt> <dd> streams, linked, pointer, interactive</dd>\n",
    "    </dl>\n",
    "</div>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import holoviews as hv\n",
    "from holoviews import streams\n",
    "hv.extension('bokeh')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Y,X=(np.mgrid[0:100, 0:100]-50.)/20.\n",
    "img = hv.Image(np.sin(X**2+Y**2))\n",
    "\n",
    "# Declare pointer stream initializing at (0, 0) and linking to Image\n",
    "pointer = streams.PointerXY(x=0, y=0, source=img)\n",
    "\n",
    "# Define function to draw cross-hair and report value of image at location as text\n",
    "def cross_hair_info(x, y):\n",
    "    text = hv.Text(x+0.05, y, '%.3f'% img[x,y], halign='left', valign='bottom')\n",
    "    return hv.HLine(y) * hv.VLine(x) * text\n",
    "\n",
    "# Overlay image and cross_hair_info\n",
    "img * hv.DynamicMap(cross_hair_info, streams=[pointer])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<center><img src=\"http://assets.holoviews.org/gifs/examples/streams/bokeh/pointer_crosshair.gif\" width=300></center>"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
